package cn.fl.capital.service.impl;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.capital.api.ICapRepaymentApiService;
import cn.fl.capital.condition.CapOvdErrLogQueryCondition;
import cn.fl.capital.condition.CapRepaymentCondition;
import cn.fl.capital.dto.CapRepaymentDTO;
import cn.fl.capital.service.ICapRepaymentService;
import cn.fl.capital.transform.CapRepaymentVOTransform;
import cn.fl.capital.vo.CapRepaymentVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: 资方支付表还款情况查询 客户端服务层接口实现
 * 业务层方法名称前缀：
 * 新增：add*
 * 删除：remove*
 * 修改：modify*
 * 批量：batch*
 * 查询对象：select* get*
 * 查询集合：search*
 */
@Service
public class CapRepaymentServiceImpl implements ICapRepaymentService {

    private static final Logger logger = LoggerFactory.getLogger(CapRepaymentServiceImpl.class);

    @Autowired
    private ICapRepaymentApiService capRepaymentApiService;
    @Override
    public Pager searchListPage(Pager page) throws BaseException {
        if(null == page) {
            page = new Pager();
            page.setCondition(new CapRepaymentCondition());
        }
        page=this.capRepaymentApiService.searchRepaymentLogListPage(page);
        if(CollectionUtils.isNotEmpty(page.getResultList())){
            List<CapRepaymentVO> voList= CapRepaymentVOTransform.toVOList((List<CapRepaymentDTO>)page.getResultList());
            page.setResultList(voList);
        }
        return page;
    }

    @Override
    public Map<String,Object> selectCapRepaymentSum(CapRepaymentCondition capRepaymentCodition) throws BaseException {
        return capRepaymentApiService.selectCapRepaymentSum(capRepaymentCodition);
    }

    @Override
    public List<CapRepaymentVO> selectPaySchDList(CapRepaymentCondition capRepaymentCodition) throws BaseException {

        List<CapRepaymentDTO>  list=   capRepaymentApiService.selectPaySchDList(capRepaymentCodition);
        if(CollectionUtils.isNotEmpty(list)){
            return  CapRepaymentVOTransform.toVOList(list);
        }
        return null;
    }
}
